<%@ page import="com.goodedeeds.webapp.controller.SchoolAction" %>
<%@ page import="com.goodedeeds.webapp.controller.ProjectAction" %>
<%@ page import="com.goodedeeds.webapp.controller.ResourcePageAction" %>
<%@ page import="com.goodedeeds.domain.resource.School" %>
<%@ page import="com.goodedeeds.domain.resource.Project" %>
<%@ page import="com.goodedeeds.webapp.controller.AddressAction" %>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%--@elvariable id="actionBean" type="com.goodedeeds.webapp.controller.SchoolAction"--%>
<%@ include file="/WEB-INF/jsp/include/taglibs.jsp"%>
<div style="text-align: center; font-size: 1.5em;">View School</div>
<div>School Key: ${actionBean.school.schoolKey}</div>
<div>School Id: ${actionBean.school.schoolId}</div>
<div>School Name: ${actionBean.school.schoolName}</div>
<div>School Description: ${actionBean.school.schoolDescription}</div>
<div>School Created Date: ${actionBean.school.createdDate}</div>
<div>School Modified Date: ${actionBean.school.modifiedDate}</div>
<div>School Status: ${actionBean.school.schoolStatus}
</div>
<div>
    School Address
    <c:choose>
        <c:when test="${actionBean.schoolAddress != null}">
        <div>Address ID: ${actionBean.schoolAddress.addressId}</div>
        <div>Address1: ${actionBean.schoolAddress.address1}</div>
        <div>Address2: ${actionBean.schoolAddress.address2}</div>
        <div>City: ${actionBean.schoolAddress.city}</div>
        <div>State: ${actionBean.schoolAddress.state}</div>
        <div>Zip: ${actionBean.schoolAddress.zip}</div>
        <div>
            <stripes:link href="<%=AddressAction.URL%>" event="edit">
                <stripes:param name="addressId" value="${actionBean.schoolAddress.addressId}"/>
                Edit Address
            </stripes:link>
        </div>
    </c:when>
    <c:otherwise>
        <stripes:link href="<%=AddressAction.URL%>" event="edit">Add Address
            <stripes:param name="parentResourceType" value="<%=School.RT_SCHOOL%>"/>
            <stripes:param name="parentResourceId" value="${actionBean.school.schoolId}"/>
        </stripes:link>
    </c:otherwise>
    </c:choose>
</div>
<stripes:link href="<%=ProjectAction.URL%>" event="edit">Create Project
    <stripes:param name="parentResourceType" value="<%=School.RT_SCHOOL%>"/>
    <stripes:param name="parentResourceId" value="${actionBean.school.schoolId}"/>
</stripes:link>
<c:if test="${!empty actionBean.projects}">
<div>
    <table>
        <c:forEach items="${actionBean.projects}" var="project">
            <tr>
                <td>${project.projectId}</td>
                <td>${project.projectKey}</td>
                <td>${project.projectName}</td>
                <td>
                    <stripes:link href="<%=ProjectAction.URL%>" event="view">
                        <stripes:param name="projectId" value="${project.projectId}"/>
                        View
                    </stripes:link>
                    |
                    <stripes:link href="<%=ProjectAction.URL%>" event="edit">
                        <stripes:param name="projectId" value="${project.projectId}"/>
                        Edit
                    </stripes:link>
                    |
                    <stripes:link href="<%=ResourcePageAction.URL%>" event="list">
                        <stripes:param name="pageResourceType" value="<%=Project.RT_PROJECT%>"/>
                        <stripes:param name="pageResourceId" value="${project.projectId}"/>
                        Pages
                    </stripes:link>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>
</c:if>
<div>
    <stripes:link href="<%=SchoolAction.URL%>" event="edit">
        <stripes:param name="schoolId" value="${actionBean.school.schoolId}"/>
        Edit
    </stripes:link>
</div>